<?php
/**
 * Note: *
 * Date: 2022/7/12
 */
namespace App\Http\Controllers\Admin;

use App\Models\Game\Center\UuidWhiteList;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;

class UuidWhiteListController extends CurdController
{
    protected string $classModel = UuidWhiteList::class;

    protected array $searchFields = [
        'uuid' => self::FIELD_TYPE_NORMAL,
    ];

    /**
     * 存储校验
     * @return mixed
     */
    public function storeBefore(Request $request)
    {
        $request->validate([
            'uuid' => [
                'required',
                'alpha_dash',
                Rule::unique('gameCenter.uuid_white_list'),
            ],
            'remark' => 'required',
        ]);
    }

    /**
     * 更新校验
     * @return mixed
     */
    public function validateUpdate(Request $request)
    {
        $request->validate([
            'uuid' => [
                'required',
                'alpha_dash',
                Rule::unique('gameCenter.uuid_white_list')->whereNot('id', $request->id),
            ],
            'remark' => 'required',
        ]);
    }
}
